<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>每日生產進度</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
	
    <link rel="stylesheet" href="./4/lumen/bootstrap.css" media="screen">
    <link rel="stylesheet" href="./_assets/css/custom.min.css">
  </head>
  <body>
  
  <div class="container" >
  
		<div class="row">
		<div class="form-group row">
		  <div class="col-sm-4 " ><h2>操機人員總數:</div>
		  <div class="col-sm-2"><h2 id ="sum_person">128人</h3></div>
		  <div class="col-sm-1" ></div>
		  <div class="col-sm-2 " ><h2>日期:</div>
		  <div class="col-sm-3">
		  <input class="form-control" placeholder="2018-06-25" id="Times" type="text">
		  </div>
		</div>	
		<form>
			<div id="Jexcelbox"></div>
		</form>
		
		<hr  width="90%" style="height:3px;" color="#000000"/>
		
		<form>
			<div id="Jexcelbox1"></div>
		</form>
		</div>
	</div>
    <link rel="stylesheet" type="text/css" href="./jexcel-master/dist/css/jquery.jexcel.css" />
    <script src="./_vendor/jquery/dist/jquery.min.js"></script>
	<script src="./jexcel-master/dist/js/jquery.jexcel.js"></script>
    <script src="./_vendor/popper.js/dist/umd/popper.min.js"></script>
    <script src="./_vendor/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="./_assets/js/custom.js"></script>
	<script>
	Plan_data = null; 
	var sum=34;
		column=[
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		{ type:'text', wordWrap:true },
		];		
					
		colHeader=[				
			'产品类型','产品系列','固','焊','点','切','分','编',
			];
		colHeader1=[				
			'产品类型','产品系列','固','焊','点','切','分','编',
			];
						
		colWidth=[140,110,110,110,110,110,110,110,
			];
		$('#Jexcelbox').jexcel({ data:Plan_data,
			// Allow column delete
			allowDeleteColumn:false,
			// Allow row dragging
			rowDrag:false,
			columns:column,
			colHeaders:colHeader,
			colWidths:colWidth
		});
		$('#Jexcelbox1').jexcel({ data:Plan_data,
			// Allow column delete
			allowDeleteColumn:false,
			// Allow row dragging
			rowDrag:false,
			columns:column,
			colHeaders:colHeader1,
			colWidths:colWidth
		});
		Times =GetDateStr(0);
		$("#Times").val(Times);
		console.log(Times);
		
		
		function refreshDiv1() {
			$.ajax({
			type:'POST',
			url: "sum_EMC.php",//POST傳一個超長字串到後端
			data:"&Times="+Times,
			dataType : "json",
			async: false,
			success: function(data){
				Plan_data = data;
				console.log(Plan_data);
				
				var myobj=eval(data);  
				//console.log(typeof myobj);//将JSON转换为数组
				
					//for(var j=1;j<10;j++){
					//sum=sum+parseInt(myobj[0][j]);//对操机员数进行求和
					//}
					
				console.log(sum);
				$('#Jexcelbox').jexcel({ data:Plan_data,
					allowDeleteColumn:false,
					rowDrag:false,
					columns:column,
					colHeaders:colHeader,
					colWidths:colWidth
				});
			}
		}); 
		}
		function refreshDiv2() {
			$.ajax({
				type:'POST',
				url: "sum_PCT.php",//POST傳一個超長字串到後端
				data:"&Times="+Times,
				dataType : "json",
				async: false,
				success: function(data){
					Plan_data = data;
					var myobj=eval(data);  
					console.log(typeof myobj);//将JSON转换为数组
					
						for(var j=1;j<10;j++){
						sum=sum+parseInt(myobj[0][j]);
						}
						console.log(sum);
						document.getElementById("sum_person").innerHTML=sum+"人";
						$("#sum_person").val(sum);
					$('#Jexcelbox1').jexcel({ data:Plan_data,
						allowDeleteColumn:false,
						rowDrag:false,
						columns:column,
						colHeaders:colHeader1,
						colWidths:colWidth
					});
				}
			});
		
		}
		
		
		
		$.ajax({
			type:'POST',
			url: "sum_EMC.php",//POST傳一個超長字串到後端
			data:"&Times="+Times,
			dataType : "json",
			async: false,
			success: function(data){
				Plan_data = data;
				console.log(Plan_data);
				
				var myobj=eval(data);  
				console.log(typeof myobj);//将JSON转换为数组
				
					for(var j=1;j<10;j++){
					//console.log(parseInt(myobj[i][j]));
					sum=sum+parseInt(myobj[0][j]);
					}
				console.log(sum);
				//console.log(datas);
				$('#Jexcelbox').jexcel({ data:Plan_data,
					// Allow column delete
					allowDeleteColumn:false,
					// Allow row dragging
					rowDrag:false,
					columns:column,
					colHeaders:colHeader,
					colWidths:colWidth
				});
			}
		}); 
	
		$.ajax({
			type:'POST',
			url: "sum_PCT.php",//POST傳一個超長字串到後端
			data:"&Times="+Times,
			dataType : "json",
			async: false,
			success: function(data){
				Plan_data = data;
				var myobj=eval(data);  
				console.log(typeof myobj);//将JSON转换为数组
				
					for(var j=1;j<10;j++){
					sum=sum+parseInt(myobj[0][j]);
					}
					console.log(sum);
					document.getElementById("sum_person").innerHTML=sum+"人";
					$("#sum_person").val(sum);
				$('#Jexcelbox1').jexcel({ data:Plan_data,
					allowDeleteColumn:false,
					rowDrag:false,
					columns:column,
					colHeaders:colHeader1,
					colWidths:colWidth
				});
			}
		});
		
		function GetDateStr(AddDayCount) {//获取时间
				var dd = new Date();
				dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
				var y = dd.getFullYear();
				var m = dd.getMonth()+1;//获取当前月份的日期
				var d = dd.getDate();
				//var hh = dd.getHours();  //获取当前小时数(0-23)
				//var min = dd.getMinutes();
				//var ss = dd.getSeconds();
				return y + "-" + m + "-" + d;
			}
			
			
		$(function() {//5分钟发送一次ajax请求
			var div1Flag = setInterval(refreshDiv1, 1000*5);
			var div1Flag = setInterval(refreshDiv2, 1000*5);
			
		});	
			
	</script>
	
  </body>
</html>



